package com.niiwoo.civet.trade.service.local.notify.impl;

import com.niiwoo.civet.trade.dao.entity.Project;
import com.niiwoo.civet.trade.enums.NotifyTypeEnum;
import com.niiwoo.civet.user.dto.request.UserLetterRequestDTO;
import com.niiwoo.civet.user.enums.MessageTemplateKeyEnum;
import com.niiwoo.civet.user.enums.UserLetterTypeEnum;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public class ProjectFlowMiscarryCancerBorrowerNotifier extends AbstractBorrowNotifier<Project> {

    // 用户在借款退回、借款审核通过待确认时取消借款标的
    // JS014 借款人
    // 通知: 借款项目流标通知 / 您好，您的借款项目【项目名称】已流标。原因为：您取消了借款标的。
    @Override
    protected UserLetterRequestDTO getUserLetterRequestDTO(UserNotifyInfo info) {
        BorrowUserNotifyInfo p = (BorrowUserNotifyInfo) info;
        UserLetterRequestDTO letterRequest = new UserLetterRequestDTO();
        // 通知
        List<Object> params = Arrays.asList(p.getProjectId(), p.getProjectTitle());
        letterRequest.setLetterTemplateEnum(MessageTemplateKeyEnum.LetterTemplateKeyEnum.PROJECT_FLOW_MISCARRY_CANCER_BORROWER);
        letterRequest.setLetterTemplateParamList(params);
        letterRequest.setToUserId(p.getUserId());
        letterRequest.setProjectId(p.getProjectId());
        letterRequest.setUserLetterTypeEnum(UserLetterTypeEnum.ONLY_LETTER);
        return letterRequest;
    }

    @Override
    protected NotifyTypeEnum getType() {
        return NotifyTypeEnum.JS014;
    }

}
